﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Half_Sibling : RelationBase
    {
        private static Half_Sibling _singleton = new Half_Sibling();
        public static Half_Sibling Instance
        {
            get { return _singleton; }
        }

        private Half_Sibling() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Half_Sibling IFF a and b share exactly one parent
            return (a.Mother == b.Mother && a.Father != b.Father) ||
                (a.Father == b.Father && a.Mother != b.Mother);
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Mother.Instance, Father.Instance });
        }
    }
}
